from http import HTTPStatus
from fastapi import APIRouter
from loguru import logger
from code.app.services.api_call import APICall
from code.app.services.image_generation_object import PortraitStypeRepaint
from code.app.services.response import Response
from code.app.utils.object_utils import convert_to_dict

# 人像风格重绘接口路由
portrait_app = APIRouter()


@portrait_app.post('/portrait-style-repaint/create/task')
def create_task(request_param: PortraitStypeRepaint.PortraitStypeRepaintRequest) -> Response:
    _input = convert_to_dict(request_param.input)
    api_response = APICall.async_call(model=request_param.model,
                                      input=_input)
    logger.info(f'portrait-style-repaint create_task api_response：{api_response.__str__()}')
    return Response.from_response(api_response)



